<template>
  <div>
    <div class="tp-content">
      <el-card
        v-for="(item, index) in topicList"
        :key="index"
        style="
          width: 368px;
          height: 90px;
          margin: 0 10px 10px 0;
          cursor: pointer;
        "
        shadow="hover"
        @click="handleClick(item.menuId)"
      >
        <div class="card-body flex">
          <img :src="item.menuIcon" style="width: 60px; height: 60px" />
          <div>
            <h1>{{ item.menuName }}</h1>
            <p>共收录{{ item.collectionSort.split(",").length }}个资源目录</p>
          </div>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted } from "vue";
import { mAxios } from "~/utils/axios/axios.js";
import { ElMessage } from "element-plus";
import { useRouter } from "vue-router";
const router = useRouter()
const topicList = ref([]);
onMounted(() => {
  mAxios.get("group/topic").then((res) => {
    let resp = JSON.parse(res.data.data);
    topicList.value = resp.data;
  });
});
const handleClick = (menu) => {
  router.push({
    path: '/recommend/detail',
    query: {
      menuId: menu
    }
  })
};
</script>

<style lang="scss" scoped>
.tp-content {
  width: 83%;
  margin: 30px auto 0;
  display: flex;
  flex-wrap: wrap;
}
.card-body > div {
  margin: 10px 0 0 10px;
  p {
    margin-top: 10px;
    font-size: 14px;
    color: #94a3b8;
  }
}
:deep(.el-card__body) {
  padding: 15px;
}
</style>